﻿using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;

namespace SharpSoft.Data
{
    /// <summary>
    /// the db type "money" in clr
    /// </summary>
    public struct Money
    {
        public Money(float value)
        {
            this.Value = value.ToString();
        }
        public Money(double value)
        {
            this.Value = value.ToString();
        }
        public Money(decimal value)
        {
            this.Value = value.ToString();
        }
        public Money(int value)
        {
            this.Value = value.ToString();
        }

        private string Value;

        public decimal ToDecimal()
        {
            return decimal.Parse(this.Value);
        }

        public static implicit operator decimal(  Money money)
        {
            return decimal.Parse(money.Value);
        }
        public static implicit operator double(Money money)
        {
            return double.Parse(money.Value);
        }
        public static implicit operator float(Money money)
        {
            return float.Parse(money.Value);
        }
        public static implicit operator int(Money money)
        {
            return int.Parse(money.Value);
        }
        public static implicit operator long(Money money)
        {
            return long.Parse(money.Value);
        }
    }
}
